<template>
  <div class="mod-company__company">
    <el-form :inline="true" :model="state.dataForm" @keyup.enter="state.getDataList()">

      <el-form-item>
        <el-input v-model="state.dataForm.companyname" placeholder="公司名" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="state.dataForm.platform" placeholder="平台" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="state.dataForm.country" placeholder="国家" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="state.dataForm.continent" placeholder="所属大洲" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="state.getDataList()">查询</el-button>
      </el-form-item>

<!--      <el-form-item>-->
<!--        <el-button v-if="state.hasPermission('company:company:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>-->
<!--      </el-form-item>-->
<!--      <el-form-item>-->
<!--        <el-button v-if="state.hasPermission('company:company:delete')" type="danger" @click="state.deleteHandle()">删除</el-button>-->
<!--      </el-form-item>-->
    </el-form>
    <el-table v-loading="state.dataListLoading" :data="state.dataList" border @selection-change="state.dataListSelectionChangeHandle" style="width: 100%">
      <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
              <el-table-column prop="companyname" label="公司名称" header-align="center" align="center" width="200"></el-table-column>
              <el-table-column prop="platform" label="平台" header-align="center" align="center" width="100"></el-table-column>
<!--              <el-table-column prop="headoffice" label="总部" header-align="center" align="center"></el-table-column>-->
              <el-table-column prop="website" label="网站" header-align="center" align="center" width="100"></el-table-column>
<!--              <el-table-column prop="fax" label="传真" header-align="center" align="center"></el-table-column>-->
<!--              <el-table-column prop="services" label="服务" header-align="center" align="center"></el-table-column>-->
<!--              <el-table-column prop="branches" label="分部" header-align="center" align="center"></el-table-column>-->
<!--              <el-table-column prop="companyregisnumber" label="公司注册编号" header-align="center" align="center"></el-table-column>-->
<!--              <el-table-column prop="turnover" label="年收入" header-align="center" align="center"></el-table-column>-->
              <el-table-column prop="numberofemployees" label="员工数" header-align="center" align="center" ></el-table-column>
              <el-table-column prop="yearofestablishment" label="公司建立年份" header-align="center" align="center" ></el-table-column>
              <el-table-column prop="membersince" label="注册平台时间" header-align="center" align="center" ></el-table-column>
<!--              <el-table-column prop="expirydate" label="有效时间" header-align="center" align="center"></el-table-column>-->
              <el-table-column prop="country" label="国家" header-align="center" align="center"></el-table-column>
              <el-table-column prop="city" label="城市" header-align="center" align="center"></el-table-column>
              <el-table-column prop="email" label="邮箱" header-align="center" align="center" width="100"></el-table-column>
<!--              <el-table-column prop="information" label="简介" header-align="center" align="center"></el-table-column>-->
<!--              <el-table-column prop="address" label="地址" header-align="center" align="center"></el-table-column>-->
<!--              <el-table-column prop="crawled" label="已爬取" header-align="center" align="center"></el-table-column>-->
              <el-table-column prop="salesperson" label="销售员" header-align="center" align="center"></el-table-column>
              <el-table-column prop="tracklock" label="锁定" header-align="center" align="center" ></el-table-column>
              <el-table-column prop="continent" label="所属大洲" header-align="center" align="center" ></el-table-column>
            <el-table-column label="操作" fixed="right" header-align="center" align="center" width="150">
        <template v-slot="scope">
          <el-button v-if="state.hasPermission('company:company:info')" type="primary" link @click="showInfoHandle(scope.row.companyname)">详情</el-button>
<!--          <el-button v-if="state.hasPermission('company:company:update')" type="primary" link @click="addOrUpdateHandle(scope.row.companyname)">修改</el-button>-->
<!--          <el-button v-if="state.hasPermission('company:company:delete')" type="primary" link @click="state.deleteHandle(scope.row.companyname)">删除</el-button>-->
        </template>
      </el-table-column>
    </el-table>
    <el-pagination :current-page="state.page" :page-sizes="[10, 20, 50, 100]" :page-size="state.limit" :total="state.total" layout="total, sizes, prev, pager, next, jumper" @size-change="state.pageSizeChangeHandle" @current-change="state.pageCurrentChangeHandle"> </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update ref="addOrUpdateRef" @refreshDataList="state.getDataList">确定</add-or-update>
    <show-info ref="showInfoRef">确定</show-info>
  </div>
</template>

<script lang="ts" setup>
import useView from "@/hooks/useView";
import { reactive, ref, toRefs } from "vue";
import AddOrUpdate from "./company-add-or-update.vue";
import ShowInfo from "./company-info.vue";

const view = reactive({
  deleteIsBatch: true,
  getDataListURL: "/company/company/page",
  getDataListIsPage: true,
  exportURL: "/company/company/export",
  deleteURL: "/company/company",
  dataForm:{
    companyname:"",
    platform:"",
    country:"",
    continent:""
  }
});

const state = reactive({ ...useView(view), ...toRefs(view) });

const addOrUpdateRef = ref();
const addOrUpdateHandle = (companyname:string) => {
  addOrUpdateRef.value.init(companyname);
};

const showInfoRef = ref();
const showInfoHandle = (companyname:string) => {
  showInfoRef.value.init(companyname);
};

</script>
